package com.wangdao.wechatmall.controller.wx;

import com.wangdao.wechatmall.bean.pojo.User;
import com.wangdao.wechatmall.bean.vo.admin.BaseRespVo;
import com.wangdao.wechatmall.bean.vo.wx.WXUserIndexVO;
import com.wangdao.wechatmall.service.admin.OrderService;
import com.wangdao.wechatmall.service.admin.UserService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ZhangXiao on 2021/7/12
 */

@RestController
@RequestMapping("wx/user")
public class WXUserIndexController {

    @Autowired
    OrderService orderService;

    @Autowired
    UserService userService;


    @GetMapping("index")
    public BaseRespVo Index() {
        Subject subject = SecurityUtils.getSubject();
        String username = (String) subject.getPrincipals().getPrimaryPrincipal();
        int userId = userService.selectId(username);

        WXUserIndexVO userIndexVO = orderService.selectOrderStatus(userId);
        return BaseRespVo.ok(userIndexVO);
    }

}
